<template>
  <div id="home">
    <div class="header">
      <el-input v-model="val" @input="handleSearch" />
      <el-button type="primary" class="test" @click="mockApi">{{ test }}</el-button>
    </div>
    <!-- <div class="header">
      {{ val }}
    </div> -->
    <div class="content">
      其实毛玻璃的模糊效果技术上比较简单，只是用到了 css 滤镜（filter）中的 blur
      属性。但是要做一个好的毛玻璃效果，需要注意很多细节。其实毛玻璃的模糊效果技术上比较简单，只是用到了 css
      滤镜（filter）中的 blur 属性。但是要做一个好的毛玻璃效果，需要注意很多细节。
    </div>
  </div>
</template>
<script>
import { debounce, throttle } from '@/utils/common'
export default {
  name: 'home',
  data() {
    return {
      test: '模拟API',
      val: '',
    }
  },
  created() {},
  methods: {
    /* 节流 */
    mockApi: throttle(function () {
      console.log('节流点击')
      this.$request.login().then((res) => {
        console.log(res)
      })
    }, 1000),
    /* 防抖 */
    handleSearch: debounce(function (val) {
      console.log('防抖请求', val)
      this.$request.querylabel().then((res) => {
        console.log(res)
      })
    }, 500),
  },
}
</script>

<style lang="scss">
#home {
  color: white;
  padding: 40px 20px;
  background: #7171c7;
  .header {
    display: flex;
    width: 500px;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
    .el-button {
      margin-left: 10px;
    }
  }
  .test {
    width: 100px;
    margin: 0 auto;
    display: block;
  }
  .content {
    width: 800px;
    position: relative;
    margin: 2rem auto;
    padding: 1em;
    background: hsla(0, 0%, 100%, 0.25) border-box;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 0 0 1px hsla(0, 0%, 100%, 0.3) inset, 0 0.5em 1em rgba(0, 0, 0, 0.6);
    text-shadow: 0 1px 1px hsla(0, 0%, 100%, 0.3);
    &::before {
      content: '';
      position: absolute;
      top: 0;
      right: 0;
      bottom: 0;
      left: 0;
      margin: -30px;
      z-index: -1;
      -webkit-filter: blur(10px);
      filter: blur(10px);
    }
  }
}
</style>
